package com.yangjie.web.jsf.viewcontroller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandlerImpl;

public class AccessDeniedHandler extends AccessDeniedHandlerImpl {
	private static Logger logger = Logger.getLogger(AccessDeniedHandler.class);

	private static final String LOG_TEMPLATE = "AccessDeniedHandlerApp:  User attempted to access a resource for which they do not have permission.  User %s attempted to access %s";

	@Override
	public void handle(HttpServletRequest _request,
			HttpServletResponse _response, AccessDeniedException _exception)
			throws IOException, ServletException {
		setErrorPage("/login.xhtml");

		super.handle(_request, _response, _exception);
	}
}